/* 
 * 	This file is part of VPN Monitor Project 7..

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package monitor.gui;

import java.util.EnumMap;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import monitor.Monitor;
import monitor.gui.GuiControl.SettingsEnum;
import monitor.gui.Start.StartStop;

@SuppressWarnings("serial")
class Gui extends JFrame {
	private Log log = null;
	private Start start = null;
	private Settings settings = null;
	
	Gui(GuiControl control, EnumMap<SettingsEnum, String> settings){
		createFrame(control, settings);
	}
	
	Log getLog(){
		return log;
	}
	
	EnumMap<SettingsEnum, Boolean> getLimitsUsed(){
		return start.getLimitsUsed();
	}
	
	EnumMap<SettingsEnum, Double> getLimitsLevel(){
		return start.getLimitsLevel();
	}
	
	String[] getNetworks(){
		return start.getNetworks();
	}
	
	String getApplications(){
		return start.getApplications();
	}
	
	void changeStartStop(StartStop option){
		start.changeStartStop(option);
	}
	
	EnumMap<SettingsEnum, Double> getLogLevels(){
		return settings.getLogLevels();
	}
	
	EnumMap<SettingsEnum, Double> getTimerLevels(){
		return settings.getTimerLevels();
	}
	
	int getDiagramSample(){
		return settings.getDiagramSample();
	}
	
	private void createFrame(GuiControl control, EnumMap<SettingsEnum, String> settings){
		this.setVisible(true);
		this.setSize(600,200);
		this.setTitle(Monitor.APPLICATION_NAME);
		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		this.addWindowListener(control);
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.addTab("Start", start = new Start(control, settings));
		tabbedPane.addTab("Settings", this.settings = new Settings(control, settings));
		tabbedPane.addTab("Log", log = new Log(control, settings));
		tabbedPane.addTab("Info", new Info(control, settings));
		tabbedPane.addTab("Diagram", new Diagram(control, settings));
		tabbedPane.addTab("About", new About(control, settings));
		this.add(tabbedPane);
		this.pack();
		this.validate();
	}
}